package edu.zsl.service.impl;

import edu.zsl.mapper.AccountMapper;
import edu.zsl.pojo.Account;
import edu.zsl.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements AccountService {
    
    private final AccountMapper accountMapper;
    @Autowired
    public AccountServiceImpl(AccountMapper accountMapper) {
        this.accountMapper = accountMapper;
    }
    
    @Override
    public boolean validate(String username, String password) {
        Account dbAccount = accountMapper.getAccount(username);
        if(dbAccount != null && dbAccount.getPassword().equals(password)){
            return true;
        }
        return false;
    }
    
    @Override
    public void insertAccount(Account account) {
        accountMapper.insertAccount(account);
    }
}
